{extend name="base" /}
{block name="content"}
<div class="g-main">
    <div class="m-main-title">
        <div class="m-container-fluid">
            <a href="{:url('index/welcome')}"><i class="icon icon-home"></i>首页</a>
            <span class="icon-angle-right"></span>
            <span>系统</span>
            <span class="icon-angle-right"></span>
            <span>分销管理</span>
            <span class="icon-angle-right"></span>
            <span>商家审核</span>
            <a class="u-flush"><i class="icon-repeat"></i></a>
        </div>
    </div>
    <div class="m-main-content">
        <div class="m-container">
            <table class="m-table">
                <tr>
                    <th>
                        <div class="m-options cf">
                            <!-- <div class="m-opts fl"><a href="{:url('add')}" class="u-btn"><i class="icon-plus"></i>添加会员</a></div> -->
                            <div class="m-search fr">
                                <form action="" class="layui-form">

                                    <input type="submit" class="u-btn u-search" value="查看" />
                                </form>
                            </div>
                        </div>
                    </th>
                </tr>
            </table>
            <form class="layui-form">
                <table class="m-table mt-10">
                    <tbody class="datas">
                    <tr>
                        <th width="5%">ID</th>
                        <th width="20%">商家名称</th>
                        <th width="10%">所属用户</th>
                        <th width="15%">商家图标</th>
                        <th width="15%">审核状态</th>
                        <th width="15%">创建时间</th>
                        <th width="15%">操作</th>
                    </tr>
                    {foreach name="data" item="v"}
                    <tr>
                        <td>{$v.id}</td>
                        <td>{$v.business_name}</td>
                        <td>{$v.member_name}</td>
                        <td><img src="{$v.business_icon_url}" alt="" style="display: block; width: 50px; height: 50px;" /></td>
                        <td>{$v.business_status_txt}</td>
                        <td>{$v.created_at}</td>
                        <td>
                            <a href="#" name="examine" data-type="yes" data-id="{$v.id}" title="通过">通过</a>
                            <a href="#" name="examine" data-type="no" data-id="{$v.id}" title="拒绝">拒绝</a>
                            <a href="{:url('show', ['business_id' => $v.id])}" title="商家详情">商家详情</a>
                        </td>
                    </tr>
                    {/foreach}
                    </tbody>
                </table>
            </form>
            {include file="public:page" /}
        </div>
    </div>
</div>
{/block}
{block name="extrajs"}
<script>
    layui.use('layer', function () {
        var layer = layui.layer,
            $ = layui.jquery;
        $("a[name='examine']").click(function (){
            var type = $(this).attr('data-type');
            var id   = $(this).attr('data-id');
            if (type == "yes"){
                layer.confirm('确定通过审核吗?', {icon: 3, title:'提示'}, function(index){
                    //do something
                    $.post('/manage/business/examine',{
                        id:id,
                        type:type
                    },function (res) {
                        layer.close(index);
                        layer.alert(res.message, function(index){
                            //do something
                            layer.close(index);
                            window.location.reload();
                        });
                    });
                });
            }else{
                layer.prompt({
                    formType: 2,
                    value: '',
                    title: '拒绝原因',
                    area: ['800px', '350px'] //自定义文本域宽高
                }, function(value, index, elem){
                    $.post('/manage/business/examine',{
                        id:id,
                        type:type,
                        remarks:value
                    },function (res) {
                        layer.close(index);
                        layer.alert(res.message, function(index){
                            //do something
                            layer.close(index);
                            window.location.reload();
                        });

                    });

                });
            }

        });


    });

</script>
{include file="laypage" /}

{/block}